#include<cstdio>
#include<cstring> 
#include<iostream>
using namespace std;

const int MaxN = 53;
const int MaxM = 53;
const int MaxNM = MaxN * MaxM;

char map[MaxN][MaxM];
pair<int, int> que[MaxNM];
bool visit[MaxN][MaxM];
int dir[4][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0}};

bool BFS(int x, int y, char color){
	int head = 0, tail = 0;
	int edge = 0;
	
	que[tail++] = make_pair(x, y);
	visit[x][y] = true;
	for(; head < tail; head++){
		int nowx = que[head].first, nowy = que[head].second;
		
		for(int i = 0; i < 4; i++){
			int nextx = nowx + dir[i][0], nexty = nowy + dir[i][1];
			
			if(map[nowx][nowy] == map[nextx][nexty]){
				edge++;
				if(!visit[nextx][nexty]){
					que[tail++] = make_pair(nextx, nexty);
					visit[nextx][nexty] = true;
				}
			}
		}
	}
	return edge >= tail * 2;
}

int main(){
	int n, m;
	bool ans = false;
	
	cin >> n >> m;
	for(int i = 1 ; i <= n; i++){
		scanf("%s", map[i] + 1);
	}
	memset(visit, false, sizeof(visit));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++) {
			if(!visit[i][j]){
				ans |= BFS(i, j, map[i][j]);
			}
		}
	}
	printf("%s", ans ? "Yes" : "No");
	return 0;
}
